<template>
  <div class="brand_source_detail">
    <c-title :text="info.title" :hide="false"></c-title>
    <div class="member">
      <div class="member_img">
        <img :src="info.logo" alt="" />
      </div>
      <div class="member_detail">
        <div class="name">{{ info.name }}</div>
        <div class="time">{{ info.created_at }}</div>
      </div>
    </div>
    <div class="source_detail_box">
      <div class="headtitle">{{ info.title }}</div>
      <p class="share_text" v-html="info.content"></p>
      <viewer :images="info.images" class="goods_box">
        <div class="img" v-for="(img, i) in info.images" :key="i">
          <img :src="img" />
        </div>
        <div class="video" v-if="info.videos && info.videos.video_url">
          <video
            :id="'video' + i"
            :src="info.videos.video_url"
            :poster="info.videos.video_image"
            style="width: 100%; height: 100%;"
            @play="onPlayerPlay(i)"
            x5-video-player-type="h5"
            controls
            x5-video-player-fullscreen="true"
          ></video>
        </div>
      </viewer>
    </div>
    <div class="detail_box" v-if="info.goods && info.goods_id !== 0">
      <div class="good" @click="toGood">
        <img v-if="info.goods" :src="info.goods.thumb" alt="" class="good_img" />
        <div class="good_detail">
          <div class="title">{{ info.goods.title | escapeTitle }}</div>
          <div class="price">{{ $i18n.t("money") }}{{ info.goods.has_option == 1? info.goods.min_price+'-'+info.goods.max_price :info.goods.price }}</div>
        </div>
      </div>
    </div>
    <!-- <van-goods-action>
      <van-goods-action-icon style="margin-right: 7.63rem">
        <template #default>
          <span style="font-size: 0.69rem; color: #6e6e79">收藏</span>
        </template>
        <template #icon>
          <i class="iconfont icon-bc_like_normal" style="font-size: 1.3rem"></i>
        </template>
      </van-goods-action-icon>
      <van-goods-action-button type="warning" text="加入购物车" />
      <van-goods-action-button type="danger" text="立即购买" />
    </van-goods-action> -->
  </div>
</template>
<script>
export default {
  data() {
    return {
      info: []
    };
  },
  activated() {
    this.getData();
  },
  methods: {
    async getData() {
      let { data, msg, result } = await $http.post("plugin.material-center.api.centerlist.detail", { id: this.$route.params.id }, "");
      if (result) {
        this.info = data;
      } else {
        this.$toast(msg);
      }
    },
    toGood(){
      this.$router.push(this.fun.getUrl("goods", { id: this.info.goods_id }));
    }
  }
};
</script>
<style lang="scss" scoped>
.source_detail_box {
  padding: 0.63rem 1.03rem;
  box-sizing: border-box;
  .goods_box {
    display: flex;
    flex-wrap: wrap;
    // max-height: 21.875rem;
    overflow: hidden;

    .video {
      // width: 6.9375rem;
      // height: 6.9375rem;
      overflow: hidden;
      margin-bottom: 0.375rem;
      position: relative;
    }

    .img {
      // width: 6.64rem;
      // height: 7.34rem;
      overflow: hidden;
      border-radius: 0.25rem;
      // background: #f2f2f2;
      margin-right: 0.28rem;
      margin-bottom: 0.375rem;

      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }

    .img:nth-child(3n) {
      margin: 0;
    }
  }
  .headtitle {
    font-weight: 500;
    font-size: 1.13rem;
    color: #00001c;
    line-height: 1.5rem;
    text-align: left;
    margin-bottom: 0.94rem;
  }
  .share_text {
    font-weight: 400;
    font-size: 0.94rem;
    color: #00001c;
    line-height: 1.5rem;
    text-align: left;
  }
}

.brand_source_detail {
  background: #ffffff;
  min-height: 100vh;
  padding-bottom: 50px;
}
.member {
  display: flex;
  align-items: center;
  padding: 0.63rem 1.03rem;
  .member_img {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    background: #737373;
    border-radius: 50%;
    margin-right: 0.5rem;
    img {
      width: 100%;
      height: 100%;
      border-radius: 50%;
    }
  }
  .member_detail {
    flex: 1;
    text-align: left;
    .name {
      font-weight: bold;
      font-size: 0.94rem;
    }
    .time {
      font-size: 0.81rem;
      color: #999999;
    }
  }
}
.pos_bottom {
  position: fixed;
  bottom: 0;
  width: 100%;
  padding: 0.28rem 0.75rem;
  box-sizing: border-box;
  background: #ffffff;
  display: flex;
  .collect {
    flex: 1;
  }
  .pos_bottom_r {
    width: 5rem;
  }
}
.detail_box {
  padding: 0.66rem 0.75rem;
  box-sizing: border-box;
  .good {
    padding: 0.63rem;
    box-sizing: border-box;
    background: #f9f9f9;
    border-radius: 0.63rem;
    display: flex;
    .good_img {
      flex-shrink: 0;
      width: 3.13rem;
      height: 3.13rem;
      background: #ffffff;
      border-radius: 0.5rem;
      margin: 0;
      margin-right: 0.5rem;
    }

    .good_detail {
      flex: 1;
      text-align: left;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      .title {
        font-weight: bold;
        font-size: 0.88rem;
        line-height: 1rem;
        color: #00001c;
      }
      .price {
        font-weight: 500;
        font-size: 0.94rem;
        line-height: 1rem;
        color: #f15353;
      }
    }
  }
}
</style>
